﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DataAccess;
using BastInfos.Models;
using BastInfos.Models.Publication;

namespace BastInfos.Controllers
{
    public class PublicationController : Controller
	{
		public ActionResult List()
		{
			IEnumerable<Publication> publications = DataRepository.Get<Publication>()
				.OrderByDescending(p => p.CreationDate);

			return View(new PublicationListModel { Publications = publications });
		}

		public ActionResult Year(int year)
		{
			IEnumerable<Publication> publications = DataRepository.Get<Publication>()
				.Where(p => p.CreationDate.Year == year)
				.OrderByDescending(p => p.CreationDate);

			return View("List", new PublicationListModel { Publications = publications, Year = year });
		}
    }
}
